package com.android.likeweixin.model;

import java.util.List;

import android.text.TextUtils;

public class FriendDynamic {
	/**
	 * 动态id
	 */
	public String newsId;

	/**
	 * 动态时间
	 */
	public long newsTime;

	/**
	 * 用户名
	 */
	public String realName = "张三";

	/**
	 * 用户名id
	 */
	public String useId = "张三";
	/**
	 * 发送内容
	 */
	public String newsContent = "测试内容；倒萨";
	/**
	 * 图片集合
	 */
	public List<String> pics;
	/**
	 * 评论数据集合
	 */
	public List<Comment> mComments;
	/**
	 * 赞数据集合
	 */
	public List<Praise> mPraises;
	/**
	 * 刷新数据的时间，以服务器时间为准
	 */
	private static String curTime = "";
	/**
	 * 登录者的用户id
	 */
	private static String loginUserId = "";
	/**
	 * 登录者的用户名
	 */
	private static String loginUserName = "";

	public static void setRefreshTime(String refreshTime) {
		if (TextUtils.isEmpty(curTime)) {
			refreshTime = curTime;
		}
	}

	public static String getRefreshTime() {
		return curTime;
	}

	public static void setLoginUserId(String userId) {
		if (TextUtils.isEmpty(loginUserId)) {
			loginUserId = userId;
		}
	}

	public static String getLoginUserId() {
		return loginUserId;
	}

	public static void setLoginUserName(String username) {
		if (TextUtils.isEmpty(loginUserName)) {
			loginUserName = username;
		}
	}

	public static String getLoginUserName() {
		return loginUserName;
	}

	/**
	 * 评论类
	 */
	public static class Comment {
		/**
		 * 评论id
		 */
		public String commentId = "";
		/**
		 * 新闻id
		 */
		public String newsId = "";
		/**
		 * 回复id
		 */
		public String userId = "";
		/**
		 * 回复
		 */
		public String realName;
		/**
		 * 被回复者id
		 */
		public String replyUserId = "";
		/**
		 * 被回复者，当回复的是这条动态本身，本字段为空
		 */
		public String replyRealName;

		/**
		 * 内容
		 */
		public String commentContent;
	}

	/**
	 * 赞
	 */
	public static class Praise {
		/**
		 * 赞的用户名
		 */
		public String realName;
		/**
		 * 用户id
		 */
		public String userId;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((newsContent == null) ? 0 : newsContent.hashCode());
		result = prime * result + ((newsId == null) ? 0 : newsId.hashCode());
		result = prime * result + (int) (newsTime ^ (newsTime >>> 32));
		result = prime * result
				+ ((realName == null) ? 0 : realName.hashCode());
		result = prime * result + ((useId == null) ? 0 : useId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		FriendDynamic other = (FriendDynamic) obj;
		if (newsContent == null) {
			if (other.newsContent != null)
				return false;
		} else if (!newsContent.equals(other.newsContent))
			return false;
		if (newsId == null) {
			if (other.newsId != null)
				return false;
		} else if (!newsId.equals(other.newsId))
			return false;
		if (newsTime != other.newsTime)
			return false;
		if (realName == null) {
			if (other.realName != null)
				return false;
		} else if (!realName.equals(other.realName))
			return false;
		if (useId == null) {
			if (other.useId != null)
				return false;
		} else if (!useId.equals(other.useId))
			return false;
		return true;
	}

}
